//package com.cn.service;
//
//import com.rabbitmq.client.Channel;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.annotation.*;
//import org.springframework.amqp.support.AmqpHeaders;
//import org.springframework.messaging.handler.annotation.Headers;
//import org.springframework.messaging.handler.annotation.Payload;
//import org.springframework.stereotype.Service;
//
//import java.util.Map;
//
///**
// * @Author jiangwang
// * @Created by 2020/10/14 11:34
// * @Description: 基于注解的消费者
// */
//@Service
//public class RabbitConsumerService
//{
//
//    private static final Logger logger = LoggerFactory.getLogger(RabbitConsumerService.class);
//
//    //订阅违法信息
//    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "test", durable = "true"),
//            exchange = @Exchange(name = "CY_TMS", durable = "true", type = "topic"),
//            key = "cy_test"))
//    @RabbitHandler
//    public void receiveMessage(@Payload String obj, @Headers Map<String, Object> headers, Channel channel)
//    {
//        try
//        {
//            logger.info("接受到数据：" + obj);
//            //mq数据主动签收
//            Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
//            channel.basicAck(deliveryTag, false);
//        }
//        catch (Exception e)
//        {
//            logger.error(obj, e);
//        }
//    }
//}
